# coding: utf-8
from kafka import KafkaProducer
from kafka import KafkaConsumer
import time,random
from kafka import KafkaProducer

#stuInfo
# name = ['Tom','Jesson','Tank','Hui']
# gender = ['0','1']
# birthdayYear = random.randint(1998, 2000)
# birthdayMonth= random.randint(1, 12)
# birthdayDay= random.randint(1, 27)
# semester = ["1","2","3","4","5","6","7","8"]

# pro1
def pro1(aa):
    # studentID_1 = random.randint(1994, 2022)
    # studentID_2 = random.randint(2001, 9999)
    # studentID = str(studentID_1) + str(studentID_2)
    className = ["210711","210712","210713","210714","210715","210716","210717","210718","210719","210720","210721"]
    na = random.randint(0, 10)
    studentID = className[na]

    # Name
    names = ['Tank', 'Jack', 'Marry', 'Tom', 'Jesson']
    name_1 = random.randint(0, 4)
    name = names[name_1] + str(name_1)

    # Date
    student_1 = random.randint(1994, 2022)
    student_2 = random.randint(10, 12)
    student_3 = random.randint(1, 30)
    student_date = str(student_1) + str(student_2) + str(student_3)

    # xuehao
    phone = random.randint(1492326111, 1512400000)

    # Semester
    semester = random.randint(1, 8)

    # StudentStatus
    # statuss = ['A', 'L']
    status = "A" if aa % 13 != 0 else "L"
    # status = statuss[v]

    # sex
    sex = [0, 1, 2]
    vs = random.randint(1, 2)
    sex_value = sex[vs]

    print(aa, studentID, name, student_date, phone, semester, status, sex_value)
    # print(studentID,name,phone,semester,status , file=file)
    return str(studentID) + '\t' + str(name) + '\t' + str(student_date) + '\t' + str(phone) + '\t' \
           + str(semester) + '\t' + str(status) + '\t' + str(sex_value)

def pro3(i):
    studentID_1 = random.randint(2000, 2021)
    studentID_2 = random.randint(101, 999)
    studentID = str(studentID_1) + str(studentID_2)

    # Name
    names = ['Drinks', 'Pencil', 'Notebook', 'Chewing', 'Toothpaste ']
    name_1 = random.randint(0, 4)
    name = names[name_1] + str(name_1)

    # Amout
    Amout = random.randint(1, 100)

    # Price
    Price = random.randint(1, 100)

    # Goods
    # statuss = ['U', 'D']
    # v = random.randint(0, 1)
    status = "U" if i % 13 != 0 else "D"
    # status = statuss[v]

    print(i, studentID, name, Amout, Price, status)
    # print(studentID,name,phone,semester,status , file=file)
    return  str(studentID) + '\t' + str(name) + '\t' + str(Amout) + '\t' + str(Price) + '\t' + str(status) + '\n'

def pro5(i):
    # Books
    studentID_1 = random.randint(2000, 2021)
    studentID_2 = random.randint(101, 999)
    studentID = str(studentID_1) + str(studentID_2)

    # Name
    names = ['HistoryBook', 'GeographyBook', 'ChemistryBook', 'MathematicsBook', 'DatastructureBook']
    name_1 = random.randint(0, 4)
    name = names[name_1] + str(name_1)
    Type = ['HistoryClass', 'GeographyClass', 'ChemistryClass', 'MathematicsClass', 'DatastructureClass']
    Price = Type[name_1]
    # Amount
    Amout = random.randint(1, 100)

    # Type
    # names = ['HistoryBook', 'GeographyBook', 'chemistryBook', 'MathematicsBook', 'DatastructureBook']
    # Price = random.randint(1,100)

    # Goods
    # statuss = ['A', 'B']
    # v = random.randint(0, 1)
    # status = statuss[v]
    status = "B" if i % 13 != 0 else "A"

    print(i, studentID, name, Amout, Price, status)
    # print(studentID,name,phone,semester,status , file=file)
    return str(studentID) + '\t' + str(name) + '\t' + str(Amout) + '\t' + str(Price) + '\t' + str(status) + '\n'

def pro7(i):
    # Books
    # studentID_1 = random.randint(2000, 2021)
    # studentID_2 = random.randint(101, 999)
    # studentID = str(studentID_1) + str(studentID_2)
    className = ["210711", "210712", "210713", "210714", "210715", "210716", "210717", "210718", "210719", "210720",
                 "210721"]
    na = random.randint(0, 10)
    studentID = className[na]

    # Name
    names = ['Tank', 'Jack', 'Marry', 'Tom', 'Jesson']
    name_1 = random.randint(0, 4)
    name = names[name_1] + str(name_1)

    # Class
    classs = ['Hadoop', 'Java', 'Python', 'Linux', 'Mysql']
    name_class = random.randint(0, 4)
    className = classs[name_class]

    # Time
    num_class = [12, 34, 56, 78]
    num = num_class[random.randint(0, 3)]
    time_str = str(random.randint(2020, 2021)) + str(random.randint(1, 12)) + str(random.randint(1, 29)) + str(
        random.randint(1, 24)) + str(num)
    # Amout = random.randint(1 ,100)

    # Type
    # names = ['HistoryBook', 'GeographyBook', 'chemistryBook', 'MathematicsBook', 'DatastructureBook']
    # Price = random.randint(1,100)

    # Goods
    # statuss = ['A', 'L']
    # v = random.randint(0, 1)
    # status = statuss[v]
    status = "A" if i % 13 != 0 else "B"

    print(i, studentID, name, className, time_str, status)

    return str(studentID) + '\t' + str(name) + '\t' + str(className) + '\t' + str(time_str) + '\t' + str(status) + '\n'

def pro9(i):
    # Books
    studentID_1 = random.randint(2000, 2021)
    studentID_2 = random.randint(101, 999)
    studentID = str(studentID_1) + str(studentID_2)

    # sweater
    names = ['Sweater', 'Skirt', 'Shoe', 'Stock', 'DowmJack']
    name_1 = random.randint(0, 4)
    name_cloth = names[name_1] + str(name_1)

    #  # Class
    # classs = ['Hadoop', 'Java', 'Python', 'Linux', 'Mysql']
    # name_class = random.randint(0, 4)
    # className = classs[name_class]

    # Time
    num_class = [12, 34, 56, 78]
    num = num_class[random.randint(0, 3)]
    time_str = str(random.randint(2020, 2021)) + str(random.randint(1, 12)) + str(random.randint(1, 29))
    # Amout = random.randint(1 ,100)

    # Type
    names = ['HistoryBook', 'GeographyBook', 'chemistryBook', 'MathematicsBook', 'DatastructureBook']
    Price = random.randint(1, 100)

    # Goods
    # statuss = ['Y', 'N']
    # v = random.randint(0, 1)
    # status = statuss[v]
    status = "Y" if i % 13 != 0 else "N"

    print(i, studentID, name_cloth, Price, time_str, status)
    # print(studentID,name,phone,semester,status , file=file)
    return str(studentID) + '\t' + str(name_cloth) + '\t' + str(Price) + '\t' + str(time_str) + '\t' + str(status) + '\n'

if __name__ == "__main__":
 producer = KafkaProducer(bootstrap_servers='cheng:9092')
 for line in range(1, 10000000):
    # stuInfo
    print("------------pro1---------------")
    pro1_str = pro1(line)
    print("------------pro3---------------")
    pro3_str = pro3(line)
    print("------------pro5---------------")
    pro5_str = pro5(line)
    print("------------pro7---------------")
    pro7_str = pro7(line)
    print("------------pro9---------------")
    pro9_str = pro9(line)

    time.sleep(1)

